package com.ruoyi.material.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.material.domain.BaseFileLabel;
import com.ruoyi.material.service.IBaseFileLabelService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 素材标签记录Controller
 * 
 * @author ruoyi
 * @date 2021-07-23
 */
@RestController
@RequestMapping("/material/file_label")
public class BaseFileLabelController extends BaseController
{
    @Autowired
    private IBaseFileLabelService baseFileLabelService;

    /**
     * 查询素材标签记录列表
     */
    @PreAuthorize("@ss.hasPermi('material:file_label:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseFileLabel baseFileLabel)
    {
        startPage();
        List<BaseFileLabel> list = baseFileLabelService.selectBaseFileLabelList(baseFileLabel);
        return getDataTable(list);
    }

    /**
     * 导出素材标签记录列表
     */
    @PreAuthorize("@ss.hasPermi('material:file_label:export')")
    @Log(title = "素材标签记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BaseFileLabel baseFileLabel)
    {
        List<BaseFileLabel> list = baseFileLabelService.selectBaseFileLabelList(baseFileLabel);
        ExcelUtil<BaseFileLabel> util = new ExcelUtil<BaseFileLabel>(BaseFileLabel.class);
        return util.exportExcel(list, "素材标签记录数据");
    }

    /**
     * 获取素材标签记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('material:file_label:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(baseFileLabelService.selectBaseFileLabelById(id));
    }

    /**
     * 新增素材标签记录
     */
    @PreAuthorize("@ss.hasPermi('material:file_label:add')")
    @Log(title = "素材标签记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseFileLabel baseFileLabel)
    {
        return toAjax(baseFileLabelService.insertBaseFileLabel(baseFileLabel));
    }

    /**
     * 修改素材标签记录
     */
    @PreAuthorize("@ss.hasPermi('material:file_label:edit')")
    @Log(title = "素材标签记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseFileLabel baseFileLabel)
    {
        return toAjax(baseFileLabelService.updateBaseFileLabel(baseFileLabel));
    }

    /**
     * 删除素材标签记录
     */
    @PreAuthorize("@ss.hasPermi('material:file_label:remove')")
    @Log(title = "素材标签记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(baseFileLabelService.deleteBaseFileLabelByIds(ids));
    }

}
